<?php

/* @var $this yii\web\View */

use yii\helpers\Url;
use yii\helpers\Html;
use common\helpers\Render;
use common\models\User;
use common\models\UserSkill;
use common\models\UserJob;
use common\models\UserUpload;
use common\models\UserEducation;

$this->addCrumbs('设计师列表', 'user/user-designer');
$this->title = '审核简历';
?>

<div class="box-content gap">
    <div class="flyer-form pane">
        <div class="form-item">
            <div class="item-inline">
                <div class="input-title">用户名</div>
                <div class="input-inline input-mid"><?= Html::encode($user->username) ?></div>
            </div>
            <div class="item-inline">
                <div class="input-title">所属角色</div>
                <div class="input-inline input-mid"><span class="flyer-status blue thin"><?= User::$roleSelector[$user->role]['title'] ?></span></div>
            </div>
        </div>
        <div class="form-item">
            <div class="item-inline">
                <div class="input-title">手机号</div>
                <div class="input-inline input-mid"><?= Html::encode($user->mobile) ?></div>
            </div>
            <div class="item-inline">
                <div class="input-title">邮箱</div>
                <div class="input-inline input-mid"><?= Html::encode($user->email) ?></div>
            </div>
        </div>
    </div>
    <div class="data-title mt-20px mb-10px"><i class="icon-book"></i> 教育经历</div>
    <div class=" flyer-table">
        <table id="info-table" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="first"><i class="icon-flag"></i> 学校</th>
                <th><i class="icon-time"></i> 开始时间</th>
                <th><i class="icon-time"></i> 结束时间</th>
                <th><i class="icon-flag"></i> 学历学位</th>
                <th><i class="icon-desktop"></i> 专业</th>
            </tr>
            </thead>
            <tbody>
            <?php
                if($user->educations) {
                    foreach($user->educations as $edu) { ?>
                        <tr>
                            <td class="first"><?= $edu['school'] ?></td>
                            <td><?= $edu['begin'] ?></td>
                            <td><?= $edu['finish'] ?></td>
                            <td><?= Render::show(UserEducation::$degreeSelector, $edu['degree']) ?></td>
                            <td><?= $edu['major'] ?></td>
                        </tr>
                    <?php }
                }
                else { ?>
                    <tr><td colspan="5"><i class="icon-ban-circle"></i> 暂未添加任何受教育信息！</td></tr>
                <?php }
            ?>
            </tbody>
        </table>
    </div>
    <div class="data-title mt-20px mb-10px"><i class="icon-legal"></i> 工作经历</div>
    <div class=" flyer-table">
        <table id="info-table" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="first"><i class="icon-flag"></i> 公司</th>
                <th><i class="icon-time"></i> 开始时间</th>
                <th><i class="icon-time"></i> 结束时间</th>
                <th><i class="icon-desktop"></i> 岗位</th>
                <th><i class="icon-desktop"></i> 工作性质</th>
            </tr>
            </thead>
            <tbody>
            <?php
                if($user->jobs) {
                    foreach($user->jobs as $edu) { ?>
                        <tr>
                            <td class="first"><?= $edu['company'] ?></td>
                            <td><?= $edu['begin'] ?></td>
                            <td><?= $edu['finish'] ?></td>
                            <td><?= $edu['post'] ?></td>
                            <td><?= Render::show(UserJob::$natureSelector, $edu['nature']) ?></td>
                        </tr>
                    <?php }
                }
                else { ?>
                    <tr><td colspan="5"><i class="icon-ban-circle"></i> 暂未添加任何工作信息！</td></tr>
                <?php }
            ?>
            </tbody>
        </table>
    </div>
    <div class="data-title mt-20px mb-10px"><i class="icon-magic"></i> 审核作品</div>
    <div class="flyer-form pane">
        <div class="form-item">
            <?php $uploads = $user->getUploads(UserUpload::TypeDesign)->asArray()->all();
            if(empty($uploads)) {
                ?>
            <div class="warn error">没有找到 [未上传/已被释放] 任何审核作品信息！</div>
            <?php
            }
            foreach($uploads as $k => $upload) {
                ?>
            <div class="item-inline item-text mb-10px mr-5px w-380px">
                <div class="input-title">第（<?= $k + 1 ?>）份作品</div>
                <div class="input-inline image-hide001 w-380px"><a href="<?= Render::upload($upload['image']) ?>" target="_blank"><img class="fixed" src="<?= Render::upload($upload['image']) ?>"></a></div>
            </div>
                <?php }
            ?>
        </div>
    </div>
    <div class="data-title mt-20px mb-10px"><i class="icon-edit"></i> 审核简历</div>
    <form class="flyer-form pane" id="flyer-create" action="<?= Url::to('@web/user/user-resume?id='.$user['id']) ?>" method="post">
        <div class="form-item">
            <div class="item-inline checker">
                <div class="input-title">等级</div>
                <div class="input-inline input-mid"><?= User::$levelSelector[$user->level][title]?></div>
            </div>
            <div class="item-inline checker">
                <div class="input-title">月薪</div>
                <div class="input-inline"><input class="flyer-input" type="text" name="salary" value="<?= Render::value($user, 'salary') / 100 ?>" placeholder="money."></div>
            </div>
            <div class="item-inline checker">
                <div class="input-title">芝麻信用分</div>
                <div class="input-inline"><input class="flyer-input" type="text" name="alipay_score" value="<?= Render::value($user, 'alipay_score') ?>" readonly="readonly" placeholder="650."></div>
            </div>
        </div>
        <div class="form-item">
            <div class="item-block">
                <div class="input-block tr bdn"><button class="flyer-button normal border-round" id="save-button" type="submit"><i class="icon-save"></i> 保 存</button></div>
            </div>
        </div>
        <textarea id="flyer-create-json" data-form="#flyer-create" style="display:none;"><?= User::checker('ensume') ?></textarea>
        <input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken() ?>">
    </form>
</div>
<script src="<?= Render::static('flyer/flyer.class.js') ?>"></script>
<script src="<?= Render::static('flyer/checker.class.js') ?>"></script>
<script>
    $(document).ready(function() {
        // Form 元素初始化
        (new flyer).init({ form: '#flyer-create' });
        // 表单数据验证
        (new checker).init({ ruleDom: '#flyer-create-json' });
    });
</script>